//
//  ViewController.swift
//  viewcontroller_test
//
//  Created by 潘茹燕 on 16/2/26.
//  Copyright © 2016年 海南开工信息技术有限公司. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var textView: UITextView!
    
    @IBAction func onClickChangeButton(sender: AnyObject) {
        
        
        let path = NSBundle.mainBundle().pathForResource("area", ofType: "plist")
        
        let dict = NSMutableDictionary(contentsOfURL: NSURL(fileURLWithPath: path!))
        
        dict?.setValue("zengsiyu@21cn.com", forKey: "email")
        dict?.setValue("male", forKey: "gender")
        dict?.setValue(nil, forKey: "name")
        
        dict?.writeToFile(path!, atomically: true)
        
        
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let dict = NSMutableDictionary(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("area", ofType: "plist")!))
        
        //let content = String(dict!)
        
        //textView.text = content
        
        
        dict?.setValue("zengsiyu", forKey: "email")
        
        
        let path = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0]
        
        let savePath = "\(path)/data.plist"
        NSLog(savePath)
        
        dict?.writeToFile(savePath, atomically: true)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

